package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.GxAssess;
import com.ruoyi.system.service.IGxAssessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * assessController
 * 
 * @author ruoyi
 * @date 2022-04-24
 */
@RestController
@RequestMapping("/system/assess")
public class GxAssessController extends BaseController
{
    @Autowired
    private IGxAssessService gxAssessService;

    /**
     * 查询assess列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GxAssess gxAssess)
    {
        startPage();
        List<GxAssess> list = gxAssessService.selectGxAssessList(gxAssess);
        return getDataTable(list);
    }

    /**
     * 导出assess列表
     */
    @Log(title = "assess", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxAssess gxAssess)
    {
        List<GxAssess> list = gxAssessService.selectGxAssessList(gxAssess);
        ExcelUtil<GxAssess> util = new ExcelUtil<GxAssess>(GxAssess.class);
        util.exportExcel(response, list, "assess数据");
    }

    /**
     * 获取assess详细信息
     */
    @GetMapping(value = "/{assessId}")
    public AjaxResult getInfo(@PathVariable("assessId") Long assessId)
    {
        return AjaxResult.success(gxAssessService.selectGxAssessByAssessId(assessId));
    }

    /**
     * 新增assess
     */
    @Log(title = "assess", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxAssess gxAssess)
    {
        return toAjax(gxAssessService.insertGxAssess(gxAssess));
    }

    /**
     * 修改assess
     */
    @Log(title = "assess", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxAssess gxAssess)
    {
        return toAjax(gxAssessService.updateGxAssess(gxAssess));
    }

    /**
     * 删除assess
     */
    @Log(title = "assess", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assessIds}")
    public AjaxResult remove(@PathVariable Long[] assessIds)
    {
        return toAjax(gxAssessService.deleteGxAssessByAssessIds(assessIds));
    }
}
